package com.zero.manage.web.components.entity;

import com.zero.manage.web.components.base.BaseDataEntity;
import io.gitee.zerowsh.constant.RegConstant;
import io.gitee.zerowsh.validation.group.Insert;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author zero
 */
@Entity
@Table(name = "sys_dict_details")
@Getter
@Setter
@ApiModel("系统字典详情")
public class SysDictDetailsEntity extends BaseDataEntity {
    /**
     * 使用字典唯一键进行关联
     */
    @Column(name = "dict_code")
    @ApiModelProperty("系统字典编码")
    @NotBlank(message = "字典编码不能为空", groups = {Insert.class})
    private String dictCode;

    @Column(name = "sort")
    @ApiModelProperty("排序")
    @NotNull(message = "排序必填")
    private Integer sort;

    @Column(name = "value")
    @ApiModelProperty("值(存入业务表值)")
    @NotBlank(message = "值必填")
    @Length(max = 20, message = "值不能大于20个字符")
    @Pattern(regexp = RegConstant.NOT_CH_REG, message = "值" + RegConstant.NOT_CH_MSG)
    private String value;
}
